//-----------------------------------------------------------------------
// <copyright file="TagService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class TagService
    {
        #region Tag

        public static void CreateTag(Tag tag)
        {            
            try
            {
                TagDAO tagDAO = new TagDAO();
                tagDAO.CreateTag(tag);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateTagException, ex);
            }
        }        

        public static void UpdateTag(Tag tag)
        {            
            try
            {
                TagDAO tagDAO = new TagDAO();
                tagDAO.UpdateTag(tag);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateTagException, ex);
            }
        }        

        public static void DeleteTag(long tagId)
        {            
            try
            {
                TagDAO tagDAO = new TagDAO();
                tagDAO.DeleteTag(tagId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteTagException, ex);
            }
        }
        
        public static Tag GetTag(long tagId)
        {            
            try
            {
                TagDAO tagDAO = new TagDAO();
                return tagDAO.GetTag(tagId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetTagException, ex);
            }
        }                

        public static TagCollection GetTagList(TagColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                TagDAO tagDAO = new TagDAO();
                return tagDAO.GetTagList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetTagListException, ex);
            }
        }        

        public static TagCollection GetTagList(TagColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                TagDAO tagDAO = new TagDAO();
                return tagDAO.GetTagList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetTagListException, ex);
            }
        }        

	    public static TagCollection GetTagListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                TagDAO tagDAO = new TagDAO();
                return tagDAO.GetTagListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetTagListException, ex);
            }
        }        

        public static TagCollection GetTagListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                TagDAO tagDAO = new TagDAO();
                return tagDAO.GetTagListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetTagListException, ex);
            }
        }        

        #endregion
    }
}